package day09;

public class ThreadJoin {

	public static boolean isFinlish=false;
	public static void main(String[] args) {
		final Thread download = new Thread(){
			public void run() {
				for (int i = 1; i <= 100; i++) {
					System.out.println("download:" + i + "%");
					try {
						Thread.sleep(50);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				System.out.println("图片下载完成！");
				isFinlish=true;
			}
		};
		
		
		Thread show=new Thread(){
			public void run(){
				System.out.println("开始显示图片！");
				try {
					download.join();
				} catch (InterruptedException e) {
				}
				
				if(!isFinlish){
						throw new RuntimeException("图片加载错误！");
				}
				System.out.println("成功显示图片");
			}
		};
		
		download.start();
		show.start();

	}

}
